package pattern10.eventcommission;

import java.lang.reflect.InvocationTargetException;

/**
 * 具体的通知者前台秘书
 * @author wdl
 */
public class Secretary extends Notifier implements ISubject{

    @Override
    public void addListener(Object object, String methodName, Object... args) {
        System.out.println("有新的同事委托尽职尽责的放哨人!");
        this.getEventHandler().addEvent(object, methodName, args);
    }

    @Override
    public void notifyX()  {
        try {
            this.getEventHandler().notifyX();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

    private String action;
    @Override
    public String getSubjectState() {
        return action;
    }

    @Override
    public void setSubjectState(String action) {
        this.action=action;
    }
}
